﻿using System;

namespace Aeon.Emulator.Instructions.FPU
{
    internal static class Ftan
    {
        [Opcode("D9F2", Name = "fptan", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void PartialTangent(VirtualMachine vm)
        {
            var fpu = vm.Processor.FPU;
            fpu.ST0 = Math.Tan(fpu.ST0);
            fpu.Push(1.0);
        }

        [Opcode("D9F3", Name = "fpatan", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void PartialArctangent(VirtualMachine vm)
        {
            double st1 = vm.Processor.FPU.GetRegisterValue(1);
            double st0 = vm.Processor.FPU.ST0;

            vm.Processor.FPU.SetRegisterValue(1, Math.Atan2(st1, st0));
            vm.Processor.FPU.Pop();
        }
    }
}
